﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Model.Custom;
using Microsoft.Reporting.WebForms;

namespace Presentation.Web.Pages.Employee
{
    public partial class EmployeeListReport : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                EmployeeReportInfo employeeReportInfo = Session[Constants.Web.EmployeeListReportInfoKey] as EmployeeReportInfo;

                if (employeeReportInfo != null)
                {
                    ReportDataSource employeesDatasource = new ReportDataSource("Employees", employeeReportInfo.GetEmployeeList());
                    ReportDataSource searchInfosDatasource = new ReportDataSource("SearchInfos", employeeReportInfo.GetSearchInfos());
                    rvEmployeeList.Visible = true;

                    this.rvEmployeeList.LocalReport.DataSources.Clear();
                    this.rvEmployeeList.LocalReport.DataSources.Add(employeesDatasource);
                    this.rvEmployeeList.LocalReport.DataSources.Add(searchInfosDatasource);

                    this.rvEmployeeList.LocalReport.SetParameters(new ReportParameter("Title", "Employee List"));
                    this.rvEmployeeList.LocalReport.Refresh();
                }
            }
        }
    }
}